package cn.edu.fzu.delivery.remoting;

import cn.edu.fzu.delivery.remoting.dto.IpAddressDto;
import com.alibaba.fastjson.JSONObject;

/**
 * @author fangxin
 * @date 2022/11/23
 */
public class IpAddressApiImpl extends LocationApi<IpAddressDto> {

    private String ip;

    @Override
    public String getUrl() {
        return "http://ip.taobao.com/outGetIpInfo?ip=" + ip + "&accessKey=alibaba-inc";
    }


    @Override
    public IpAddressDto transfer(JSONObject result) {
        JSONObject data = result.getJSONObject("data");
        return data.toJavaObject(IpAddressDto.class);
    }


    public IpAddressDto get(String ip) {
        this.ip = ip;
        return super.get();
    }

}
